#响应用户请求的方法(页面跳转)
from Max.models import Job
from django.contrib import auth

# from django.http import HttpRequest
from django.shortcuts import render,redirect
import Max.views

def home(request):
    return render(request,'index.html')

# def android(request):
#     return render(request,'tables_android.html')

# def java(request):
#     return render(request,'tables_java.html')
#
# def php(request):
#     return render(request,'tables_php.html')
#
# def python(request):
#     return render(request,'tables_python.html')
#
# def web(request):
#     return render(request,'tables_web.html')

def index(request):
    return render(request,'index.html')


# def loginin(request):

def login(request):
    if request.method == 'GET':
        # return render(request,'loginin.html')
        return render(request,'login.html')
    elif request.method == 'POST':
        user_name=request.POST['用户名']
        pass_word = request.POST['密码']
        user = auth.authenticate(username=user_name,password=pass_word)
        if user is None:
            # return render(request,'loginin.html',{'错误':'用户名或密码错误'})
            return render(request,'login.html',{'错误':'用户名或密码错误'})
        else:
            auth.login(request,user)
            return redirect( 'home')

def logout(request):
    if request.method == 'POST':
        auth.logout(request)
        return render(request, 'index.html')
